package com.rxyb.security.password;

import com.google.common.base.Charsets;
import com.google.common.hash.Hashing;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * MD5加密
 *
 * @author duyh
 * @date 2020/5/29
 */
public class MD5PasswordEncode implements PasswordEncoder {
    @Override
    public String encode(CharSequence charSequence) {
        return Hashing.md5().hashString(charSequence, Charsets.UTF_8).toString();
    }

    @Override
    public boolean matches(CharSequence charSequence, String s) {
        return encode(charSequence).equals(s);
    }
}
